<!--_meta 作为公共模版分离出去-->
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<link rel="Bookmark" href="/favicon.ico" >
<link rel="Shortcut Icon" href="/favicon.ico" />
<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5shiv.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<![endif]-->
<link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="lib/Hui-iconfont/1.0.8/iconfont.css" />
<link rel="stylesheet" type="text/css" href="static/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/style.css" />
<!--[if IE 6]>
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<!--/meta 作为公共模版分离出去-->

<title>修改用户 - 胆款流转实时监控管理系统 v1.0</title>
<meta name="keywords" content="胆款流转实时监控管理系统 v1.0">
<meta name="description" content="胆款流转实时监控管理系统 v1.0">
</head>
<body>
<article class="page-container">
	<form action="" method="post" class="form form-horizontal" id="form-staff-info-update">
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>分公司：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<select class="select" id="companyid" name="company.companyid"></select>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>姓名：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" value="" placeholder="" id="name" name="name">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>身份证：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" value="" placeholder="" id="idCardNo" name="idCardNo" readonly="readonly">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3">手机：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="tel" class="input-text" value="" placeholder="" id="phoneNo" name="phoneNo">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3">合同终止日期：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="date" class="input-text" value="" placeholder="" id="contractEndDate" name="contractEndDate">
			</div>
		</div>
		<!-- <div class="row cl">
			<label class="form-label col-xs-4 col-sm-3">照片：</label>
			<div class="formControls col-xs-8 col-sm-9"> <span class="btn-upload form-group">
				<input class="input-text upload-url" type="text" name="uploadfile" id="uploadfile" readonly nullmsg="请添加照片！" style="width:200px">
				<a href="javascript:void();" class="btn btn-primary radius upload-btn"><i class="Hui-iconfont">&#xe642;</i> 浏览文件</a>
				<input type="file" name="photo" class="input-file">
				</span> </div>
		</div> -->
		<div class="row cl">
			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
				<input class="btn btn-primary radius" type="submit" value="&nbsp;&nbsp;提交&nbsp;&nbsp;">
			</div>
		</div>
	</form>
</article>

<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script> 
<script type="text/javascript" src="js/jquery.base64.js"></script>
<script type="text/javascript" src="lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="static/h-ui/js/H-ui.min.js"></script> 
<script type="text/javascript" src="static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本--> 
<script type="text/javascript" src="lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="lib/jquery.validation/1.14.0/jquery.validate.js"></script> 
<script type="text/javascript" src="lib/jquery.validation/1.14.0/validate-methods.js"></script> 
<script type="text/javascript" src="lib/jquery.validation/1.14.0/messages_zh.js"></script>
<script type="text/javascript" src="js/vue.js" charset="utf-8"></script>
<script type="text/javascript">
	
function queryCompany(companyid){
	$.ajax({
		url: ipAddress + 'base/company/getList',
		// url: 'http://localhost:8080/base/company/getList',
		data: {
			order: "ordercode"
		},
		beforeSend: function (request) {
			request.setRequestHeader("Authorization", "Bearer " + getToken());
		},
		method:'GET',
		success:function (data,status,request) {
			$("#companyid").append("<option value>请选择分公司</option>");
			for(var i = 0; i < data.length; i ++){
				if(companyid != null && companyid == data[i].companyid){
					$("#companyid").append("<option selected value='" + data[i].companyid + "'>" + data[i].companyname + "</option>");
				} else {
					$("#companyid").append("<option value='" + data[i].companyid + "'>" + data[i].companyname + "</option>");
				}
			}
		},
		error:function (request, msg, obj) {
			var respTxtObj = JSON.parse(request.responseText);
			console.log(respTxtObj);
			console.log(respTxtObj.error);
			console.log(respTxtObj.error_description);
		}
	});
}

$(function(){
	
	$('.skin-minimal input').iCheck({
		checkboxClass: 'icheckbox-blue',
		radioClass: 'iradio-blue',
		increaseArea: '20%'
	});
	
	$.ajax({
		url: ipAddress + '3rdpartyinfo/staffInfo/getStaffById',
		// url: 'http://localhost:8080/auth/user/getJdbcUser',
		data: {
			id: getQueryVariable("id")
		},
		beforeSend: function (request) {
			request.setRequestHeader("Authorization", "Bearer " + getToken());
		},
		method:'GET',
		success:function (data,status,request) {
			console.log(data);
			$('#idCardNo').val(data.idCardNo);
			$('#name').val(data.name);
			$('#phoneNo').val(data.phoneNo);
			$('#contractEndDate').val(data.contractEndDate);
			var enabledInt = 0;
			if(data.sex){
				$('input[name=sex][value=1]').attr('checked', 'true');
				$('input[name=sex][value=1]').parents('.iradio-blue').addClass('checked');
			} else {
				$('input[name=sex][value=0]').attr('checked', 'true');
				$('input[name=sex][value=0]').parents('.iradio-blue').addClass('checked');
			}
			var companyid = data.company != null ? data.company.companyid : '';
			queryCompany(companyid);
		},
		error:function (request, msg, obj) {
			var respTxtObj = JSON.parse(request.responseText);
			console.log(respTxtObj);
			console.log(respTxtObj.error);
			console.log(respTxtObj.error_description);
		}
	});
	
	$("#form-staff-info-update").validate({
		rules:{
			companyid:{
				required:true
			},
			name:{
				required:true,
				minlength:2,
				maxlength:20
			},
			idCardNo:{
				required:true,
				minlength:18,
				maxlength:18
			},
			phoneNo:{
				required:false
			}
		},
		onkeyup:false,
		focusCleanup:true,
		success:"valid",
		submitHandler:function(form){
			console.log(form);
			// 1.基本参数设置 
		    var options = { 
				type: 'PUT',     // 设置表单提交方式
		//         url: ipAddress + 'demo/clearingReport/save',    // 设置表单提交URL,默认为表单Form上action的路径
				url: ipAddress + '3rdpartyinfo/staffInfo/updateStaffInfo',    // 设置表单提交URL,默认为表单Form上action的路径
		        dataType: 'json',    // 返回数据类型
				headers: {
					'Authorization': "Bearer " + getToken()
				},
		        beforeSubmit: function(formData, jqForm, option){    // 表单提交之前的回调函数，一般用户表单验证
		            // formData: 数组对象,提交表单时,Form插件会以Ajax方式自动提交这些数据,格式Json数组,形如[{name:userName, value:admin},{name:passWord, value:123}]
		            // jqForm: jQuery对象,，封装了表单的元素   
		            // options: options对象
		            var str = $.param(formData);    // name=admin&passWord=123
					console.log(str);
		            var dom = jqForm[0];    // 将jqForm转换为DOM对象
		            var name = dom.name.value;    // 访问jqForm的DOM元素
		            /* 表单提交前的操作 */
		            return true;  // 只要不返回false,表单都会提交  
		        },
		        success: function(responseText, statusText, xhr, $form){    // 成功后的回调函数(返回数据由responseText获得)
		            if (responseText.code == 1000) {
		                alert("操作成功!");
		                /* 成功后的操作 */
						var index = parent.layer.getFrameIndex(window.name);
						parent.layer.close(index);
		            } else {
		                alert("操作失败!");    // 成功访问地址，并成功返回数据，由于不符合业务逻辑的失败
		            }
		        },  
		        error: function(xhr, status, err) {            
		            alert("操作失败!");    // 访问地址失败，或发生异常没有正常返回
		        },
		        clearForm: true,    // 成功提交后，清除表单填写内容
		        resetForm: true    // 成功提交后，重置表单填写内容
		    }; 
			$(form).ajaxSubmit(options);
		}
	});
});
</script> 
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>